package com.ximu.test.hibernate;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateSessionFactory {

	private static SessionFactory  sessionFactory=null;
	
	static {
		if(sessionFactory==null){
			try{
				Configuration config = new Configuration().configure("/hibernate.cfg.xml");
				sessionFactory = config.buildSessionFactory();
			}catch(HibernateException e){
				e.printStackTrace();
				System.out.print("factory error!");
			}
		}
	}
	
	public static SessionFactory getSessionFactory(){
		return sessionFactory;
	}
}